package org.yys.seata.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.yys.seata.service.StorageService;

/**
 * The type Stock controller.
 */
@RestController
@RequestMapping("/stock")
public class StockController {

    @Autowired
    private StorageService storageService;

    /**
     * Decrease string.
     *
     * @param productId the product id
     * @param count     the count
     * @return the string
     */
    @GetMapping("/decrease")
    public String decrease(@RequestParam("productId") Long productId,
                           @RequestParam("count") Integer count){

        storageService.descrease(productId,count);
        return "success";
    }
}
